package com.jqq.threaduse;

/**
 * @author 姬倩倩
 * @version 1.0
 */
public class Thread03 {
    public static void main(String[] args) throws InterruptedException {
        Hello hello = new Hello();
        Hi hi = new Hi();
        Thread thread = new Thread(hello);
        Thread thread1 = new Thread(hi);
        thread.start();
        thread1.start();
        System.out.println("main线程继续");
//        for (int i = 0; i < 8; i++) {
//            System.out.println("主线程 i=" + i+"线程名=" + Thread.currentThread().getName());
//            Thread.sleep(1000);
//        }
    }
}
class Hello implements Runnable{
    int count = 0;

    @Override
    public void run() {
        while (true){
            System.out.println("hello,world"+(++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(count == 10){
                break;
            }
        }

    }
}
class Hi implements Runnable{
    int count = 0;

    @Override
    public void run() {
        while (true){
            System.out.println("hi"+(++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(count == 5){
                break;
            }
        }

    }
}